

function say() {
    alert("LC:503");
}
say();


/**
 * @param {number[]} nums
 * @return {number[]}
 */
var nextGreaterElements = function(nums) {
    //7:58-8:15
    //循环数组
    
    var res = []

    for(var i = 0; i < nums.length; i++){
        var j = i + 1
        if(i == nums.length - 1){
            j = 0
        }
        var has = false
        for(; j < nums.length; j++){
            if(nums[j] > nums[i]){
                res.push(nums[j])
                has = true
                break
            }
        }
        //没有,表示i=1之后没有, 再检查<i的元素
        if(!has){
            for(var k = 0; k < i; k++){
                if(nums[k] > nums[i]){
                    res.push(nums[k])
                    has = true
                    break
                }
            }
            if(!has){
                res.push(-1)
            }
            
        }
    }
    return res
};
